import { createRouter, createWebHistory } from 'vue-router'

// 导入组件
import IndexView from '../views/IndexView.vue'

import LoginView from '../views/LoginView.vue'
import EmployeeManage from '../views/employee/EmployeeManage.vue'
import SearchView from '../views/search/SearchView.vue'

import UserInfoView from '../views/user/UserInfoView.vue'
import UserAvatar from '../views/user/UserAvatar.vue'
import UserResetPasswordView from '../views/user/UserResetPasswordView.vue'


import ProductInfosView from '../views/product/ProductInfosView.vue'


// 定义路由关系
const routes =[
  { // 登录界面路由
    path: '/login',
    component:LoginView
  },
  { 
    // 嵌套路由 ---> 
    path: '/',  // 父路由
    component: IndexView, // 父组件
    redirect:'/employee/infos',  // 默认路由
    children: [
      { path: '/user/info', component: UserInfoView },
      { path: '/user/avatar', component: UserAvatar },
      { path: '/user/resetPassword', component: UserResetPasswordView },
      { path: '/:category', component: SearchView },
      // { path: '/article/category', component: ArticleCategoryVue },
      { path: '/employee/infos', component: EmployeeManage },
      { path: '/product/infos', component: ProductInfosView },
      // { path: '/user/info', component: UserInfoVue },
      // { path: '/user/avatar', component: UserAvatarVue },
      // { path: '/user/resetPassword', component: UserResetPasswordVue }
  ]
  }
]


//创建路由器
const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

//导出路由
export default router
